/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.appspot.ittrick.drive.trick.task;

import com.appspot.ittrick.drive.trick.api.DriveAPIService;
import com.appspot.ittrick.drive.trick.controller.MainController;
import java.util.List;
import javafx.concurrent.Service;
import javafx.concurrent.Task;

/**
 *
 * @author takahara
 */
public class FileMoveTask extends Service<Object> {

    private String targetFileId;
    private String targetParentId;

    public void run(String targetFileId, String targetParentId) {
        this.targetFileId = targetFileId;
        this.targetParentId = targetParentId;
        this.restart();
    }

    @Override
    protected Task<Object> createTask() {
        return new Task<Object>() {
            
            @Override
            protected List<Object> call() throws Exception {
                DriveAPIService driveService = MainController.getInstance().getDriveService();
                
                driveService.moveFile(targetFileId, targetParentId);
                
                return null;
            }
        };
    }
}
